#xxxxxxxxxxxxxxxxxxxxxxxxx 添加 target
set(MY_EXE runall)
add_executable(${MY_EXE})

# 使用 target_sources 组织源文件
# 添加C++源文件
target_sources(${MY_EXE}
    PRIVATE
        main.cpp
)
#============================= 包含目录
target_include_directories(${MY_EXE} PRIVATE
    # 添加src目录
    ${CMAKE_CURRENT_SOURCE_DIR}
)

#============================= 链接CUDA库
target_link_libraries(${MY_EXE}
    PRIVATE
        common
        test_cuda
)

#============================= 拷贝运行时文件
# 定义源目录和目标目录
if(WIN32 AND EXISTS "${MY_CONAN_RUNTIME_DIR}")
    set(RUNTIME_SOURCE_DIR "${MY_CONAN_RUNTIME_DIR}")
    set(RUNTIME_DEST_DIR "${MY_PATH_BIN}/$<CONFIG>")
    # 添加自定义命令，在构建后拷贝文件
    add_custom_command(
        TARGET ${MY_EXE} POST_BUILD
        # COMMAND ${CMAKE_COMMAND} -E make_directory "${RUNTIME_DEST_DIR}"
        COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
            "${RUNTIME_SOURCE_DIR}"
            "${RUNTIME_DEST_DIR}"
        COMMENT "Copy runtime dlls, ${RUNTIME_SOURCE_DIR} -> ${RUNTIME_DEST_DIR}"
        VERBATIM
    )
endif()

#=================================== 链接到 stdc++fs
if(LINUX)
    target_link_libraries(${MY_EXE} PRIVATE stdc++fs)
endif()


#xxxxxxxxxxxxxxxxxxxxxxxxx transform RelWithDebInfo -> Debug 配置
# my_config_msvc_relwithdebinfo(${MY_EXE})

#------------ 在顶层 CMakeLists.txt 文件中设置默认启动项目
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${MY_EXE})

#------------ 设置 VS 调试器的工作目录
# set_property(TARGET ${MY_EXE} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${MY_PATH_BIN}")

#------------ 设置 VS 调试器的命令行参数
set(MY_TEST_DOSE_STAT_FILE "${MY_TESTIO_DIR}/d250905_voxel_volume_dose.npz" CACHE PATH "test dose stat file")
set_property(TARGET ${MY_EXE} PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "te_ds --file=${MY_TEST_DOSE_STAT_FILE} --v_name=volumes --d_name=doses")

#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx insatll 设置
install(TARGETS ${MY_EXE}
    RUNTIME DESTINATION bin
)
